// var arr = [1, 2, 3, 4, 5, 6, 7]
// console.log(arr.join(null))
// slice 截取 参数开始至结束值不会操作原数组
//  var a =arr.slice(2,4)
//  var a =arr.splice(2,4)
// var a ='aaaaaaaa'
// console.log(a.split(''))
// console.log(a)
// console.log(arr)

// join 将数组转换成字符串
// console.log(arr.join())
// join 重构

// function arrayJoin(arr,separator){
//     if(!arr || arr.constructor!==Array) throw new Error(arr+"not is Array");
//     if(separator===undefined) separator =","
//     separator = String(separator)
//     const str = ""
//     for(let i=0;i<arr.length;i++){
//         if(i===arr.length-1) return str+=arr[i]
//         str+=arr[i]+separator
//     }
// }
// console.log(arrayJoin(arr))

//Slice 封装
// function arraySlice(arr, start, end) {
//     if (!arr || arr.constructor !== Array) throw new Error(arr + "not is Array");
//     start = ~~start
//     if (isNaN(end)) end = arr.length;
//     ent = parseInt(end)
//     start = Number(start)
//     start = start < 0 ? (start + arr.length < 0 ? 0 : start + arr.length) : start;
//     end = end < 0 ? (end + arr.length < 0 ? 0 : end + arr.length) : end
//     let arr1 = [];
//     for (let i = start; i < end; i++) {
//         arr1[arr1.length] = arr[i]
//     }
//     return arr1
// }
// console.log(arraySlice(arr,2,4))